unit uniCadContasAPagar;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uniCadPadrao, DB, ADODB, ExtCtrls, Buttons, StdCtrls, Mask,
  DBCtrls, ComCtrls;

type
  TfrmCadContasAPagar = class(TfrmCadPadrao)
    GroupBox2: TGroupBox;
    Label2: TLabel;
    DBText2: TDBText;
    Label4: TLabel;
    DBLookupComboBox2: TDBLookupComboBox;
    Label1: TLabel;
    Label3: TLabel;
    DBEdit2: TDBEdit;
    DBEdit1: TDBEdit;
    Label5: TLabel;
    dtVencimento: TDateTimePicker;
    DS_Despesa: TDataSource;
    QR_Despesa: TADOQuery;
    procedure DBLookupComboBox2Enter(Sender: TObject);
    procedure DBLookupComboBox2Exit(Sender: TObject);
    procedure btnGravarClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    procedure p_select;
  public
    { Public declarations }
  end;

var
  frmCadContasAPagar: TfrmCadContasAPagar;

implementation

uses uniFuncBD, UniFuncoes;

{$R *.dfm}

procedure TfrmCadContasAPagar.DBLookupComboBox2Enter(Sender: TObject);
begin
  inherited;
  setCorEnter(Sender);
end;

procedure TfrmCadContasAPagar.DBLookupComboBox2Exit(Sender: TObject);
begin
  inherited;
  setCorExit(Sender);
end;

procedure TfrmCadContasAPagar.btnGravarClick(Sender: TObject);
begin
  QR_Padrao.FieldByName('dt_vencimento').AsSTring := DateToStr(dtVencimento.Date);
  inherited;

end;

procedure TfrmCadContasAPagar.p_select;
var sSQL : String;
begin
  sSQL := ' SELECT * FROM TB_CONTAS_APAGAR WHERE 1=1';
  if sCdCampo <> '' then
    sSQL := sSQL + ' AND cd_contas LIKE '+QuotedStr(sCdCampo);
  QR_Padrao.Close;
  QR_Padrao.SQL.Clear;
  QR_Padrao.SQL.Add(sSQL);
  QR_Padrao.Open;
  QR_Padrao.First;

  QR_Despesa.Close;
  QR_Despesa.SQL.Clear;
  QR_Despesa.SQL.Add('SELECT * FROM TB_DESPESA');
  QR_Despesa.Open;
end;

procedure TfrmCadContasAPagar.FormShow(Sender: TObject);
begin
  p_Select;
  inherited;

end;

end.
